package com.bosicen.crm.service.sysmanage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;

import com.bosicen.crm.dao.entity.Product;
import com.bosicen.crm.dao.entity.ProductSery;
import com.bosicen.crm.dao.entity.ProductType;
import com.bosicen.crm.dao.sysmanage.ProductDao;
import com.bosicen.crm.dao.sysmanage.ProductSeryDao;
import com.bosicen.crm.dao.sysmanage.ProductTypeDao;
import com.bosicen.crm.tools.Page;

import org.springframework.transaction.annotation.Transactional;
/**
 * 商品系列
 * @author tigerlei
 *
 */
@Service("productSeryService")
public class ProductSeryServiceImpl {
	@Autowired
	private ProductSeryDao productSeryDao;

	// @Transactional(readOnly = false,propagation=Propagation.REQUIRED,
	// rollbackFor=Exception.class)

	/****
	 * 查询列表
	 * 
	 * @param companyid
	 * @return
	 */
	public List<ProductSery> findProductSeryList(ProductSery sery) {
		List<ProductSery> list = null;
		try {
			list = this.productSeryDao.findProductSeryList(sery);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return list;
	}

	/***
	 * 新增/修改
	 * 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean saveOrUpdateProduct(ProductSery p) {
		try {
			 this.productSeryDao.saveOrUpdate(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}

	/****
	 * 按ID查询
	 * 
	 * @param companyid
	 * @return
	 */
	public ProductSery findProductSeryById(int id) {
		ProductSery productSery = null;
		try {
			productSery = this.productSeryDao.findProductSeryById(id);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return productSery;
	}

	/****
	 * 删除 
	 * 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean delProductSery(ProductSery p) {
		try {
			this.productSeryDao.delProductSery(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}
	
	public Page findProductSery4Page(Page page,int companyid){
		return productSeryDao.findProductSery4Page(page,companyid);
	}

}
